package com.sky.mapper;

import com.sky.entity.OrderDetail;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    //查询购物车集合
    public ShoppingCart queryShoppingCar(ShoppingCart shoppingCart);

    //根据id修改商品数量
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    public void updateNumberById(ShoppingCart shoppingCart);

    //存入数据
    @Insert("insert into shopping_cart(name,user_id,dish_id,setmeal_id,dish_flavor,number,amount,image,create_time) " +
            " values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    public void insert(ShoppingCart shoppingCart);

    //查询购物车
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> showShoppingCar(Long userId);

    //删除全部商品
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long currentId);

    //更新商品的数量
    void sub(ShoppingCart shoppingCart);

    //根据id删除单个商品
    @Delete("delete from shopping_cart where id = #{id}")
    void delete(ShoppingCart shoppingCart);

    /**
     * 批量新增
     * @param orderDetailList
     */
    void insertBatch(List<OrderDetail> orderDetailList);
}
